fix: hard-error on unknown 'auth' subcommands#245
Merged
Conversation
Running 'datumctl auth login' or 'datumctl auth logout' silently reprinted the auth group help and exited 0, giving users no signal the command was invalid. Login and logout moved to the top level in the context-discovery redesign (#149), but older docs and muscle memory still reach for the auth-scoped spelling. The auth command now validates its args: an unrecognized subcommand returns a UserError (exit 1) instead of a success. Names that were promoted to the top level get a targeted hint pointing at the replacement command; other unknown names get a generic error directing users to --help. Both carry a machine-readable Code (AUTH_COMMAND_MOVED, UNKNOWN_SUBCOMMAND) for structured error consumers. Bare 'datumctl auth' still prints help and exits 0; valid subcommands route unchanged. Refs #243
915b54f to
57a0be6
Compare
scotwells
approved these changes
Jul 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second half of #243. Stacked on #244 — base is
fix/auth-help-stale-login-examples; review/merge #244 first, then this retargets tomain.Problem
datumctl auth loginanddatumctl auth logoutdon't error. Cobra treats the unknown subcommand as a positional arg, theauthgroup has noRunE, so it reprints the group help and exits 0. A user following old docs or muscle memory gets no signal the command is invalid — and (before #244) the help they saw repeated the wrong spelling.Login/logout were deliberately promoted to top-level commands in the context-discovery redesign (#149, PR #149); they are not coming back under
auth. So the fix is to fail loudly and redirect, not to re-add aliases.Change
authnow validates its args (cobra.ArbitraryArgs+RunE):login,logout) → targeted error with a hint at the replacement:--help:datumctl auth→ still prints help, exits 0.list,switch,get-token,update-kubeconfig) route unchanged.Both errors carry a machine-readable
Code(AUTH_COMMAND_MOVED,UNKNOWN_SUBCOMMAND) so structured (--error-format json) consumers and agents can branch on them:Tests
internal/cmd/auth/auth_test.gocovers bare-auth-help, both moved-command hints, the generic unknown case, and that valid subcommands still resolve.go build ./...andgo test ./internal/cmd/auth/...pass.